<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Catalog</title>
</head>
<body>
<body background="../../img/bg.jpg"> 
	<font face="Berlin Sans FB Demi" color="#357EC7" size="3">
<center>
	<?
include('../auth.php');
include('../../config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {die('Failed to connect to server: ' . mysql_error());}
error_reporting (E_ALL ^ E_NOTICE);               
$db = mysql_select_db(DB_DATABASE);
if(!$db) {die("Unable to select database");}

?>
<br><br>
<h1>Stergere acces catalog</h2>
<form action="accessadd.php" method="post">
<table border="1">
<?
$sql=mysql_query("select nume from profesori");

echo '<tr><td>Nume: &nbsp;&nbsp;&nbsp;<select name="prof">';
while ($result=mysql_fetch_array($sql)) {
echo "<option>".$result['nume']."</option>";
}
echo '</select></tr></td><tr><td>Clasa: &nbsp;&nbsp;&nbsp; <select name="clasa">';
$sql1=mysql_query("select distinct nume from clase");
while ($result=mysql_fetch_array($sql1)) {
echo "<option>".$result['nume']."</option>";
}
echo "</select></tr></td>";
$sql=mysql_query("select nume from materie order by nume asc");
echo '<tr><td>Materie: <select name="mat">';
while ($result=mysql_fetch_array($sql)) {
echo "<option>".$result['nume']."</option>";
}
?>
</select></tr></td>
<tr><td><center><input type="submit" value="Sterge acces"></center></tr></td>
</table>
</form>
<?
function clean($str) {
		$str = @trim($str);
		if(get_magic_quotes_gpc()) {
			$str = stripslashes($str);
		}
		return mysql_real_escape_string($str);
	}
$nume=clean($_POST['prof']);
$clasa=clean($_POST['clasa']);
$mat=clean($_POST['mat']);	

if ($nume!='') {
$matid=mysql_fetch_array(mysql_query("select id from materie where nume='".$mat."'"));
$profid=mysql_fetch_array(mysql_query("select id from profesori where nume='".$nume."'"));

$sql64=mysql_query("delete from clase where materie_id='".$matid."' and profesor_id='".$profid."' and nume='".$clasa."')");

echo '<script type="text/javascript">
window.location = "prof.php"
</script>';
}
?>
</font>
</body>
</html>